
package ui.adapter;

import android.content.Context;
import android.support.v7.widget.DefaultItemAnimator;
import android.support.v7.widget.GridLayoutManager;
import android.view.View;
import android.widget.TextView;

import net.ck.hzq.R;

import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.List;

import Bean.MPOSBean;
import base.BaseViewHolder;
import base.SuperBaseAdapter;
import cn.finalteam.loadingviewfinal.RecyclerViewFinal;
import util.StringUtils;


/**
 * 排行榜适配器
 * Created by chenjian on 19/2/27.
 */
public class PosParentAdapter extends SuperBaseAdapter<MPOSBean.ChildrenBean> {

    List<MPOSBean.ChildrenBean> mData = new ArrayList<>();
    Context mContext;

    DecimalFormat df = new DecimalFormat("0.00");

    public PosParentAdapter(Context context, List<MPOSBean.ChildrenBean> data) {
        super(context, data);
        mContext = context;
        mData = data;
    }

    @Override
    protected void convert(BaseViewHolder holder, final MPOSBean.ChildrenBean item, final int position) {
        holder.setText(R.id.item_pick_machine_title, item.getTitle());
        TextView desc=holder.getView(R.id.item_pick_machine_info);
        if(StringUtils.isEmpty(item.getDescription())){
            desc.setVisibility(View.GONE);
        }else{
            desc.setVisibility(View.VISIBLE);
            desc.setText(item.getDescription());
        }
        RecyclerViewFinal rv = holder.getView(R.id.item_pick_machine_rv);
        rv.setLayoutManager(new GridLayoutManager(mContext,2));
        rv.setItemAnimator(new DefaultItemAnimator());
        PosAdapter adapter = new PosAdapter(mContext, item.getPosModels());
        rv.setAdapter(adapter);

    }


    @Override
    protected int getItemViewLayoutId(int position, MPOSBean.ChildrenBean item) {
        return R.layout.item_pick_machine;
    }

}
